package com.itheima.car;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Demo {
    public static void main(String[] args) {
        Car car = new CarDemo();
        Car proxy_car = (Car) Proxy.newProxyInstance(car.getClass().getClassLoader(), car.getClass().getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if ("run".equals(method.getName())) {
                    System.out.println("芜湖起飞"+args[0]);


                } else {
                    return method.invoke(car,args);
                }
                return null;
            }

    });
        proxy_car.run(10000);
        proxy_car.stop();
    }
}
